import request from '../index';

const orderUrl = '/order-server';

// 历史订单分页查询
export const pagingHistoryOrder = (params: any, page: any) => {
  return request({
    // url: `http://192.168.101.16:8082${orderUrl}/appHistoryOrder/pagingHistoryOrder`,
    url: `${orderUrl}/appHistoryOrder/pagingHistoryOrder`,
    params: params,
    extraParams: page,
    noLoading: true,
  });
};

// 历史订单详情
export const getHistoryOrder = (params: any) => {
  return request({
    // url: `http://192.168.101.16:8082${orderUrl}/appHistoryOrder/getHistoryOrder`,
    url: `${orderUrl}/appHistoryOrder/getHistoryOrder`,
    params: params,
  });
};

// 实时订单分页
export const pagingAppCurrentOrder = (params: any, page: any) => {
  return request({
    // url: `http://192.168.101.16:8082${orderUrl}/appHistoryOrder/pagingAppCurrentOrder`,
    url: `${orderUrl}/appCurrentOrder/pagingAppCurrentOrder`,
    params: params,
    extraParams: page,
    noLoading: true,
  });
};

// 异常订单分页
export const pagingAbnormalOrder = (params: any, page: any) => {
  return request({
    // url: `http://192.168.101.16:8082${orderUrl}/appAbnormalOrder/pagingAbnormalOrder`,
    url: `${orderUrl}/appAbnormalOrder/pagingAbnormalOrder`,
    params: params,
    extraParams: page,
    noLoading: true,
  });
};

//判断实时订单是否存在
export const getUserCurrentOrder = (params: any, flag: boolean = false) => {
  return request({
    url: `${orderUrl}/currentOrder/getUserCurrentOrder`,
    params: params,
    noLoading: flag,
  }).catch(() => { });
}
export const getCurrentOrderStatus = (params: any, flag: boolean = false) => {
  return request({
    url: `${orderUrl}/appCurrentOrder/getCurrentOrderStatus`,
    params: params,
    noLoading: flag,
    noToast: true,
  });
}

//待处理订单分页查询
export const pagingUnpaidOrder = (params: any, page: any) => {
  return request({
    url: `${orderUrl}/appUnpaidOrder/pagingUnpaidOrder`,
    params: params,
    extraParams: page,
    noLoading: true,
  });
};

// 待处理订单详情
export const getUnpaidOrder = (params: any) => {
  return request({
    url: `${orderUrl}/appUnpaidOrder/getUnpaidOrder`,
    params: params,
  });
};

// 小程序待支付订单计算优惠券后的价格
export const useDiscountCoupon = (params: any) => {
  return request({
    url: `${orderUrl}/appUnpaidOrder/useDiscountCoupon`,
    params: params,
  });
};

//小程序待支付订单支付
export const payUnpaidOrder = (params: any) => {
  return request({
    url: `${orderUrl}/appUnpaidOrder/payUnpaidOrder`,
    params: params,
  });
};

// 占位历史订单分页查询
export const pagingOccupyOrder = (params: any, page: any) => {
  return request({
    url: `${orderUrl}/occupyOrder/pagingOccupyOrder`,
    params: params,
    extraParams: page,
    noLoading: true,
  });
};